<?php
namespace App\Controllers\Home\Page;
use \App\Libs\Home\Home;

class Jiangping extends  \App\Libs\Base\BaseTwigAction 
{
    protected function beforeRun() {
        parent::beforeRun();
        //$this->needLogin = TRUE;
    }
	
	public function execute(){
		$key = '';
		if (isset($_COOKIE[SESSION_KEY_OPEN]) && ! empty($_COOKIE[SESSION_KEY_OPEN])) {
            $key = trim($_COOKIE[SESSION_KEY_OPEN]);
		}
		$openid = \App\Libs\Cache\Redis::get(trim($key));
		$jiangpin = \App\Libs\DB\PailePdo::instance()->findAll("select * from t_paile_choujiang where openid = ? order by ctime desc",array($openid));
		if( !empty( $jiangpin ) ){
			foreach( $jiangpin as $k=>$v ){
				$jiangpin[$k]['name'] = self::jiangpin( $v['is_user'] , $v['jiang'] );
			}
		}
		$this->addParam('jiangpin',$jiangpin);
		return parent::execute();
	}
	
	public static function jiangpin( $userIndex , $jiangIndex  ){
		$arr = array(
			'1' => array(
				'1' => array( 'name'=>'冰神卡免费体验一个月','type'=>'link','link'=>'https://m.10010.com/scaffold-show/icecream-taste?WT.mc_id=zhejiang_zhejiang_517zhengshi_0515_H5_0001&utm_source=zhejiang&utm_medium=cpc&utm_term=&utm_content=jpg&utm_campaign=zhejiang_zhejiang_517zhengshi_0515_H5_0001','info'=>''),
				'2' => array( 'name'=>'优酷会员30天','type'=>'phone','info'=>'<div style="width: 80%;">优酷会员兑奖说明：<p>1、优酷土豆黄金会员（30天）将在活动结束后7个工作日内绑定到您填写的手机号码上。</p><p>2、您的手机号码就是您的会员账号，绑定成功后会有短信通知，请注意查收！。</p></div>'),
				'3' => array( 'name'=>'哈罗单车免费骑','type'=>'link','link'=>'http://pmp1.shcccoupon.com:8998/model/event/705?button=&from=singlemessage&isappinstalled=0','info'=>'')
			),
			'2' => array(
				'1' => array( 'name'=>'100元红包电子券','type'=>'phone','info'=>'<div style="width: 80%;">100元红包电子券兑奖说明：<p>1、100元红包电子券将在活动结束后7个工作日内赠送到您填写的浙江联通号码上。</p><p>2、红包电子券可在沃钱包APP中用于兑换话费、京东、天猫等抵价券。</p><p>3、若您填写的兑奖号码为非浙江联通号码则不可获赠。</p></div>'),
				'2' => array( 'name'=>'爱奇艺会员7天体验','type'=>'phone','info'=>'<div style="width: 80%;">爱奇艺VIP会员周卡兑奖说明：<p>1、爱奇艺VIP会员周卡将在活动结束后7个工作日内为您发送奖品领取短信，请根据短信中的提示进行奖品领取。</p></div>'),
				'3' => array( 'name'=>'哈罗单车免费骑','type'=>'link','link'=>'http://pmp1.shcccoupon.com:8998/model/event/705?button=&from=singlemessage&isappinstalled=0','info'=>'')
			)
		);
		return $arr[$userIndex][$jiangIndex];
		
	}
}
